package com.hydl.power.controller;

import com.hydl.power.aop.annotation.LogAnnotation;
import com.hydl.power.pojo.PowerImage;
import com.hydl.power.pojo.PowerNewData;
import com.hydl.power.service.PowerDataService;
import com.hydl.power.service.PowerImageService;
import com.hydl.power.utils.Resp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "PowerImgController",tags = "电路图")
@RequestMapping("/powerImg")
@RestController
@CrossOrigin
public class PowerImgController {

    @Autowired
    private PowerDataService powerDataService;

    @Autowired
    private PowerImageService powerImageService;



    // @LogAnnotation(module = "电路图",description = "获取单个设备数据")
    @ApiOperation("电路图(获取单个设备数据)")
    @PostMapping("/getPowerData")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "deviceId", value = "设备id", defaultValue = "1021702588_2_25", dataType = "String"),
            @ApiImplicitParam(paramType = "query", name = "type", value = "1电压 2电流 3功率 4电能 ", defaultValue = "1", dataType = "String"),
    })
    public Resp getPowerData(String deviceId, String type) {
        List<PowerNewData> list = powerDataService.getPowerNewData(deviceId, type);
        if (list.size() != 0) {
            return Resp.success(list);

        } else {
            return Resp.fail();

        }
    }


    @ApiOperation("电路图列表")
    @PostMapping("/getPowerImage")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "token", value = "token", defaultValue = "70N9D9nrpn", dataType = "String"),
    })
    public Resp getPowerImage(String token) {
        List<PowerImage>  list= powerImageService.getPowerImage(token);
        return Resp.success(list);
    }



}



